-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default to packed for repeated primitives in proto3. #707
Conversation
Fixes stepancheg#704. In proto3, repeated primitive fields should be packed by default: https://protobuf.dev/programming-guides/encoding/#packed
Merged. Thanks!
Add a test to test crate which adds a proto3 message with repeated primitive, and checks that serialized as packed. However, given that the crate is in low maintenance mode, I accept this as is.
Test codegen can be modified to emit this information. Or proto version can be obtained from reflective API.
I think the project does not have a lot of tests for errors.
When the crate was implemented, I did not know how to do errors properly. Now I know, but as I said, crate is in low maintenance. |
Wait, I'm reverting this commit. I believe it is implemented incorrectly. I suspect the problem is in pure rust proto parser. I suspect protoc-based parser populates this field, but pure parser is not:
Also, let's add a test. |
Thanks for the review! I've added a test. I don't follow what you're saying about the pure parser not setting the packed field. I think the pure parser handles options here, and the existing tests show that packed=true/packed=false work for both protoc and pure. |
I suspect So my hypothesis is, we need to patch pure parser instead of patching codegen. |
That looks to me like
So I think both parsers treat |
Fixes #704.
Fixes #706.
I wasn't sure how to add tests for either.
For #704, I didn't see a way to distinguish which syntax was being used in a test.
For #706, I didn't see a way to have an invalid proto in a test (the parser fails before you get to the test).
I'm not sure I handled the error correctly, the output looks like:
As opposed to other errors, that have multiple layers:
There's also no line/column number, but I'm not sure if that's expected.